package com.java.tutorials.jdk7.paths;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by xuzhike on 2016/1/27.
 * http://www.java2s.com/Code/Java/JDK-7/Determiningwhethertwopathsareequivalentwithequalsmethod.htm
 * Determining whether two paths are equivalent with equals method
 */
public class Determiningwhethertwopathsareequivalentwithequal {
    public static void main(String[] args) {
        Path path1 = Paths.get("/home/docs/users.txt");
        Path path2 = Paths.get("/home/docs/users.txt");
        Path path3 = Paths.get("/home/music/A.mp3");

        testEquals(path1, path2);
        testEquals(path1, path3);
    }
    private static void testEquals(Path path1, Path path2) {
        if (path1.equals(path2)) {
            System.out.println("equal");
        } else {
            System.out.println("NOT equal");
        }
    }
}
